<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>链条Chain操作</title>
</head>
<body>
<script src="../js/chain.js"></script>
<script>
    var chain = new Chain(function (resolve, reject) {
        setTimeout(function () {
            resolve('construct')
        }, 3000)
    })

    chain.then(function (data) {
        console.log(data)
        return 'resolve-1'
    }).then(function (data) {
        console.log(data)
        return 'resolve-2'
    }).then(function (data) {
        console.log(data)
        return Chain.reject('reject-1')
    }).catch(function (data) {
        console.log(data)
        return data
    }).catch(function (data) {
        console.log(data)
        return new Chain(function (resolve, reject) {
            setTimeout(function () {
                resolve('chain-1')
            }, 2000)
        })
    }).then(function (data) {
        console.log(data)
    }).catch(function (data) {
        console.log(data)
        return data
    })
</script>
</body>
</html>